package 矩阵;

/**
 * @author tmh
 * @date 2024/11/29 17:47
 * @description
 */
public class T240搜索二维矩阵II {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length;
        int n = matrix[0].length;
        for (int i = 0; i < m; i++) {
            int left = 0;
            int right = n - 1;
            while (left < right) {
                int mid = left + right + 1 >> 1;
                if (matrix[i][mid] <= target) {
                    left = mid;
                } else {
                    right = mid - 1;
                }

            }
            if (matrix[i][right]==target){
                return true;
            }
        }
        return false;
    }
}
